home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / science / ack3d.zip / ACKOVER.C < prev    next >
Text File  |  1994-01-09  |  2KB  |  74 lines

  1. /******************* ( Animation Construction Kit 3D ) ***********************/
  2. /*            Overlay Creation Routines                 */
  3. /* CopyRight (c) 1993       Author: Lary Myers                     */
  4. /*****************************************************************************/
  5.  
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <dos.h>
  9. #include <mem.h>
  10. #include <alloc.h>
  11. #include <io.h>
  12. #include <fcntl.h>
  13. #include <time.h>
  14. #include <string.h>
  15. #include <sys\stat.h>
  16. #include "ack3d.h"
  17. #include "ackeng.h"
  18.  
  19. /****************************************************************************
  20. ** This routine "compiles" the source buffer (sBuf) into a series of draw  **
  21. ** commands to speed up the overlay drawing. The commands are then placed  **
  22. ** into the OverlayBuffer for later use. The application should use this   **
  23. ** call if it wishes to use an irregular viewport for the display.       **
  24. **                                       **
  25. ****************************************************************************/
  26. int AckCreateOverlay(ACKENG *ae,UCHAR far *sBuf)
  27. {
  28.     UINT    bPos,vPos,vLen;
  29.     UINT    len,sPos,sPos1;
  30.  
  31. vLen = (ae->WinEndY - ae->WinStartY) * BYTES_PER_ROW;
  32. vPos = ae->WinStartY * BYTES_PER_ROW;
  33. bPos = 0;
  34. sPos = vPos;
  35.  
  36. while (vLen > 0)
  37.     {
  38.     if (sBuf[sPos])
  39.     {
  40.     sPos1 = sPos;
  41.     while (vLen > 0 && sBuf[sPos1++])
  42.         vLen--;
  43.  
  44.     len = (sPos1 - sPos) - 1;
  45.     (*(int *)&ae->ScreenBuffer[bPos]) = len;
  46.     bPos += 2;
  47.     (*(int *)&ae->ScreenBuffer[bPos]) = sPos;
  48.     bPos += 2;
  49.     memmove(&ae->ScreenBuffer[bPos],&sBuf[sPos],len);
  50.     bPos += len;
  51.     sPos = sPos1;
  52.     }
  53.     else
  54.     {
  55.     sPos++;
  56.     vLen--;
  57.     }
  58.     }
  59.  
  60. (*(int *)&ae->ScreenBuffer[bPos]) = 0;
  61. bPos += 2;
  62.  
  63. ae->OverlayBuffer = malloc(bPos);
  64.  
  65. if (ae->OverlayBuffer != NULL)
  66.     {
  67.     memmove(ae->OverlayBuffer,ae->ScreenBuffer,bPos);
  68.     return(0);
  69.     }
  70.  
  71. return(ERR_NOMEMORY);
  72. }
  73.  
  74.